#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
typedef int ListNode;
struct ListNode 
{
    ListNode* next;
    int data;
};
struct ListNode* ReverseList(struct ListNode* head) {
    // write code here
    struct ListNode* ptail = head->next;
    struct ListNode* phead = head;
    struct ListNode* pcur = ptail->next;
    while (pcur != NULL)
    {
        ptail->next = phead;
        phead = ptail;
        ptail = pcur;
        pcur = pcur->next;
    }
    ptail->next = phead;
    pcur = phead = NULL;
    return ptail;
}
int main()
{
    struct ListNode* head = NULL;
    struct ListNode* phead = NULL;
    head->data = 1;
    head->next = NULL;
    phead = head->next;
    phead->data = 2;
    phead->next = NULL;
    phead = phead->next;
    phead->data = 3;
    phead->next = NULL;
    phead = phead->next;
    ReverseList(&head);
    return 0;
}